package com.facebook.scrumptious;

import android.app.Activity;
import android.content.Intent;
import android.net.Uri;
import android.os.Bundle;
import android.view.Menu;
import android.view.View;
import android.view.View.OnClickListener;
import android.widget.Button;
import android.widget.ImageView;
import android.widget.TextView;

public class DetailsActivity extends Activity {

	@Override
	protected void onCreate(Bundle savedInstanceState) {
		super.onCreate(savedInstanceState);
		setContentView(R.layout.activity_details);

		ImageView image = (ImageView) findViewById(R.id.detailsImage);
		TextView title = (TextView) findViewById(R.id.detailsTitle);
		TextView price = (TextView) findViewById(R.id.detailsPrice);
		TextView asin = (TextView) findViewById(R.id.detailsAsin);
		TextView link = (TextView) findViewById(R.id.detailsLink);
		Button button = (Button) findViewById(R.id.detailsButton);

		final Intent intent = getIntent();

		title.setText(intent.getStringExtra(Present.TITLE));
		price.setText(intent.getStringExtra(Present.PRICE));
		asin.setText(intent.getStringExtra(Present.ASIN));
		link.setText(intent.getStringExtra(Present.LINK));

		button.setOnClickListener(new OnClickListener() {
			@Override
			public void onClick(View v) {
				Intent browserIntent = new Intent(Intent.ACTION_VIEW, Uri
						.parse(intent.getStringExtra(Present.LINK)));
				startActivity(browserIntent);
			}
		});
	}

	@Override
	public boolean onCreateOptionsMenu(Menu menu) {
		getMenuInflater().inflate(R.menu.activity_details, menu);

		return true;
	}

}
